package control;
import javax.microedition.lcdui.Graphics;

public class GroupControl extends Control {
	protected Control[] controls;

	public GroupControl(int numControl) {
		controls = new Control[numControl];
	}

	public Control get(int i) {
		return controls[i];
	}

	public void setControl(int i, Control ctr) {
		controls[i] = ctr;
	}

	public boolean pointerPressed(int x, int y) {
		boolean pressed = false;
		for (int i = 0; i < controls.length; i++) {
			Control ctr = controls[i];
			if (ctr.visible()) {
				if (ctr.pointerPressed(x, y)) {
					pressed = true;
				}
			}
		}
		return pressed;
	}

	public boolean pointerReleased(int x, int y) {
		boolean pressed = false;
		for (int i = 0; i < controls.length; i++) {
			Control ctr = controls[i];
			if (ctr.visible()) {
				if (ctr.pointerReleased(x, y)) {
					pressed = true;
				}
			}
		}
		return pressed;
	}

	protected void controlPaint(Graphics g) {
		for (int i = 0; i < controls.length; i++) {
			Control ctr = controls[i];
			ctr.paint(g);
		}
	}
}
